package com.dubbo.provider.api;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * \* User: MeiZhongHao
 * \* Date: 2019-04-24
 * \* Time: 14:23
 * \* Description:
 * \
 */
public class DefaultOpenApiDispatcher implements OpenApiDispatcher {

    private final Map<String, HelloService> helloServiceCache = new ConcurrentHashMap<String, HelloService>();

    @Resource
    public void setHelloServiceCache(List<HelloService> list) {
        for (HelloService openApiService : list) {
            String openApiServiceKey = openApiService.getOpenApiMethod() + "&" + openApiService.getOpenApiVersion();
            helloServiceCache.put(openApiServiceKey, openApiService);
        }
    }

    @Override
    public String doDispatch(String key) {
        HelloService helloService = helloServiceCache.get(key);
        helloService.doService();
        return null;
    }
}